#include "fsabstractpersistentdocument.h"

#include <ipersistenceassistant.h>
#include <mimetype.h>
#include <mimetypemanager.h>

#include <QtCore/QUrl>

using namespace core;
using namespace fspersistence;

FsAbstractPersistentDocument::FsAbstractPersistentDocument(
    const QFileInfo& fileInfo, const core::IStorage* storage) :
        IPersistentDocument(),
        m_fileInfo(fileInfo),
        m_storage(storage),
        m_data()
{
}

FsAbstractPersistentDocument::~FsAbstractPersistentDocument()
{
}

QUrl FsAbstractPersistentDocument::url() const
{
    QUrl ret = QUrl::fromLocalFile(m_fileInfo.absoluteFilePath());

    return ret;
}

core::MimeType FsAbstractPersistentDocument::mimeType() const
{
    MimeType ret;

    ret = MimeTypeManager::getInstance()->mimeTypeForUrl(url());

    return ret;
}

QString FsAbstractPersistentDocument::name() const
{
    QString ret;

    ret = m_fileInfo.baseName();

    return ret;
}

const core::IStorage* FsAbstractPersistentDocument::storage() const
{
    return m_storage;
}

const QByteArray* FsAbstractPersistentDocument::serializedData() const
{
    return &m_data;
}
